/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*                
* by Dejan Nedelkovski, www.HowToMechatronics.com
* 
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
String aa="123";
uint8_t bb="1234";
const char cc="1234";
const char dd[]="1234";
const char ee[]="a";
int n=3;
struct Data_Package {
  byte X;
  byte Y;
  byte G;
  byte H;
};
int aaa;
int bbb;
int eee;
int fff;
Data_Package data;
void setup() {
//  Serial.begin(9600);
  
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  data.X = map(analogRead(A0), 0, 1023, 0, 255); // Convert the analog read value from 0 to 1023 into a BYTE value from 0 to 255
  data.Y = map(analogRead(A1), 0, 1023, 0, 255);
  
  const char text[] = "e";
  const char text2[] = "f";
//  radio.write(&text, sizeof(text));//可以发送文本常量
//  radio.write(&text2, sizeof(text2));//可以发送文本常量
//  radio.write("2222",10);//可以发送字符串常量
//  radio.write("aa=%s",&aa,sizeof(aa)+4);
//  radio.write(&bb,sizeof(bb));//可以发送字符串常量
//  radio.write(&cc,sizeof(cc));
//  radio.write(&dd,sizeof(dd));//证明可以发送a

  delay(30);
  aaa=digitalRead(2);
  bbb=digitalRead(3);
  eee=digitalRead(4);
  fff=digitalRead(5);

  if(aaa==LOW)data.G=7;
  if(bbb==LOW)data.G=8;
  if(eee==LOW)data.H=7;
  if(fff==LOW)data.H=8;
  
  radio.write(&data, sizeof(Data_Package));
  data.G=0;data.H=0;

}
